﻿using Gameplay.PVE.Utils;
using UnityEngine;

namespace Yoozoo.Gameplay.RTS
{
    /// <summary>
    /// 存放士兵渲染的数据结构
    /// </summary>
    public struct RTSUnitInfo
    {
        public Vector3 Position { get; private set; }
        public Vector3 Rotation;
        //逻辑方向
        public Vector3 Forward { get; private set; }
        //渲染方向
        public Vector3 RendererForward { get; private set; }//中间值 用于插值

        public Vector3 ActualRendererForward { get; internal set; }//实际值
        public float Scale { get; private set; }
        public float Alpha { get; private set; }
        public bool Visible { get; private set; }


        public void SetAlpha(float alpha)
        {
            Alpha = alpha;
        }
        public void SetScale(float scale)
        {
            Scale = scale;
        }

        public void SetVisible(bool visible)
        {
            Visible = visible;
        }
        public void SetPosition(Vector3 position)
        {
            
            Position = position;
        }
        public void SetForward(Vector3 forward)
        {
            Forward = forward;
        }
        public void SetRendererForward(Vector3 forward)
        {
            RendererForward = forward;
            ActualRendererForward = forward;
        }

        public void GetRendererForwardByDeltaTime(ref float deltaTime)
        {
            float diffAngle = PveUtils.GetAngle(RendererForward, Forward);

            var logicForward = Vector3.Lerp(RendererForward, Forward, 2 * deltaTime);

            ActualRendererForward = logicForward;
            if (ActualRendererForward == Forward)
            {
                RendererForward = Forward;
                deltaTime = 0;
            }
        }


    }
}
